<template>
  <div>
    <el-form :inline="true" label-width="80px">
      <el-form-item label="查询">
        <el-input
          v-model="queryParams.mobile"
          placeholder="真实姓名/手机号码/昵称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="角色">
        <el-select v-model="queryParams.role"   @keyup.enter.native="handleQuery" placeholder="角色" clearable size="small">
          <el-option
            v-for="dict in roleOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="创建时间">
        <el-date-picker
          v-model="daterange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>

      <el-form-item label="">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>

    </el-form>
    <el-table v-loading="loading" :data="postList">
      <el-table-column label="用户编号" align="center" prop="idNo"/>
      <el-table-column label="头像" align="center" prop="path">
        <template slot-scope="scope">
          <div>
            <el-popover placement="right" title="" trigger="click">
              <img :src="scope.row.path" alt="">
              <img slot="reference" :src="scope.row.path" alt="" style="max-height: 50px;max-width: 50px">
            </el-popover>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="真实姓名" align="center" prop="custName">
        <template slot-scope="scope">
          <span v-if="scope.row.custName">{{scope.row.custName}}</span>
          <span v-else class="text-warning">无</span>
        </template>
      </el-table-column>
      <el-table-column label="用户昵称" align="center" prop="nickname"/>
      <el-table-column label="手机号码" align="center" prop="mobile"/>
      <el-table-column label="用户角色" align="center" prop="role" :formatter="roleFormat"/>
      <el-table-column label="总收益" align="center" prop="amount">
        <template slot-scope="scope">
          <span>{{scope.row.amount|currencyFilter}}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createtime"/>

    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import {recommendUserList} from "@/api/channel/user";

  export default {
    props: {
      row: {
        type: Object,
        require: true
      },
      roleOptions: {
        type: Array,
        require: true
      }
    },
    data() {
      return {
        loading: false,
        postList: [],
        daterange: undefined,
        total: 0,
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          role: undefined,
          mobile: undefined,
          userId: undefined,
        },

      }
    },
    created() {
      this.queryParams.id = this.row.userId;
      console.log(this.row);

      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        recommendUserList(this.queryDateRange(this.queryParams, this.daterange)).then(response => {
          console.log(response);
          this.postList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      roleFormat(row, column) {
        return this.selectDictLabel(this.roleOptions, row.role);
      },
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      }
    }
  }
</script>

<style scoped>

</style>
